import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
  Put,
  Query,
} from '@nestjs/common';
import { SystemService } from './system.service';
import { CreateSystemDto } from './dto/create-system.dto';
import { UpdateSystemDto } from './dto/update-system.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UpdatePasswordDto } from './dto/update-password.dto';
import { query } from 'winston';

@Controller('system')
export class SystemController {
  constructor(private readonly systemService: SystemService) {}

  // 个人信息
  @Get('user/profile')
  async profile(@Req() req: any): Promise<any> {
    const user = req.user;
    return await this.systemService.getProfile(user);
  }

  // 修改信息
  @Put('user/profile')
  async updateProfile(@Body() updateUserDto: UpdateUserDto, @Req() req: any) {
    const user = req.user;
    return await this.systemService.updateProfile(user, updateUserDto);
  }

  // 重置密码
  @Put('user/profile/updatePwd')
  async updatePwd(
    @Query() updatePasswordDto: UpdatePasswordDto,
    @Req() req: any,
  ) {
    const user = req.user;
    return await this.systemService.updatePassword(user, updatePasswordDto);
  }
}
